package com.xique.door.api.factory;

import com.xique.common.core.domain.R;
import com.xique.door.api.RemoteAppUserService;
import com.xique.door.api.model.LoginAppUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author shd
 * @create 2021/12/31 10:50
 */
@Component
public class RemoteAppUserFallbackFactory implements FallbackFactory<RemoteAppUserService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteAppUserFallbackFactory.class);

    @Override
    public RemoteAppUserService create(Throwable throwable) {

        log.error("门禁服务调用失败:{}", throwable.getMessage());

        return new RemoteAppUserService() {

            @Override
            public R<LoginAppUser> getUserInfo(String loginName) {
                return R.fail("获取用户失败:" + throwable.getMessage());
            }

        };

    }
}
